<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.prime.com.tr/ui">

    <body>

        <ui:composition template="./../../Template/generalTemplate.xhtml">


            <ui:define name="content">
                <h:form>  
                     <p:growl id="growl1" showDetail="true" /> 
                    <p:panel header="Create Invoice" style="height:495px;">
                      
                        <p:dataTable id="inquiry" value="#{createInvoiceManagedBean.getDeliveryOrders()}" var="inList" paginator="true" rows="6">

                            <p:column filterBy="#{inList.id}" filterMatchMode="contains"
                                      headerText="Delivery Order ID:">
                                <h:outputText value="#{inList.id}"/>
                            </p:column>
                           <p:column filterBy="#{inList.parentSalesOrder.id}" filterMatchMode="contains"
                                      headerText="Sales Order ID:">
                                <h:outputText value="#{inList.parentSalesOrder.id}"/>
                            </p:column>
                            <p:column filterBy="#{inList.parentSalesOrder.customer.name}" filterMatchMode="contains"
                                      headerText="Client">
                                <h:outputText value="#{inList.parentSalesOrder.customer.name}"/>
                            </p:column>
                            <p:column filterBy="#{inList.shippingAddress.streetName}" filterMatchMode="contains"
                                      headerText="Delivery Location">
                                <h:outputText value="#{inList.shippingAddress.streetName},"/>
                                <h:outputText value="#{inList.shippingAddress.city}"/>
                            </p:column>
                            <p:column filterBy="#{inList.deliveryDate}" filterMatchMode="contains"
                                      headerText="Delivery Date">
                                <h:outputText value="#{inList.deliveryDate}">
                                    <f:convertDateTime pattern="dd-MM-yyyy" />
                                </h:outputText>
                            </p:column>
                              <p:column filterBy="#{inList.invoice.id}" filterMatchMode="contains"
                                      headerText="Related Invoice">
                                <h:outputText value="#{inList.invoice.id}"/>
                                
                            </p:column>
                            <p:column headerText="Action" style="text-align: center;width:90px;">

                                <p:commandButton action="#{createInvoiceManagedBean.createInvoice(inList.id)}" image="ui-icon ui-icon-check" update="growl1" ajax="false" title="Select" />        
                                       <p:confirmDialog message="Are you sure to create the inovice?"  
                                             showEffect="bounce" hideEffect="explode"  
                                             header="Create Invoice" severity="alert" widgetVar="dlg2">  

                                <p:commandButton value="Yes Sure" update="growl1" ajax="true" onclick ="confirmation.hide()"  
                                               action="#{createInvoiceManagedBean.createInvoice(inList.id)}" />  
                                <p:commandButton value="Not Yet" onclick="confirmation.hide()" type="button" />   

                            </p:confirmDialog>
                            </p:column>  
        
                        </p:dataTable>
         
                      

                    </p:panel> 

                </h:form>
            </ui:define>

        </ui:composition>

    </body>
</html>
